/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package business;

import model.Account;
import model.AccountManager;

/**
 *
 * @author Administrator
 */
public class ModifyPwdCmd extends AbstractCommand {

    @Override
    public boolean execute(Object args) {
        Account account = AccountManager.getInstance().getAccountByID(getAccountID());
        if (account == null) {
            return false;
        }
        if (account.getPwd().equals(this.oldPwd) ) {
            if(account.getOwnerID().equals(this.ownerID)) {
                account.setPwd(newPwd);
                return true;
            }
        }
        return false;
    }
    
    private String accountID;
    private String oldPwd;
    private String newPwd;
    private String ownerID;

    /**
     * @return the accountID
     */
    public String getAccountID() {
        return accountID;
    }

    /**
     * @param accountID the accountID to set
     */
    public void setAccountID(String accountID) {
        this.accountID = accountID;
    }

    /**
     * @return the oldPwd
     */
    public String getOldPwd() {
        return oldPwd;
    }

    /**
     * @param oldPwd the oldPwd to set
     */
    public void setOldPwd(String oldPwd) {
        this.oldPwd = oldPwd;
    }

    /**
     * @return the newPwd
     */
    public String getNewPwd() {
        return newPwd;
    }

    /**
     * @param newPwd the newPwd to set
     */
    public void setNewPwd(String newPwd) {
        this.newPwd = newPwd;
    }

    /**
     * @return the ownerID
     */
    public String getOwnerID() {
        return ownerID;
    }

    /**
     * @param ownerID the ownerID to set
     */
    public void setOwnerID(String ownerID) {
        this.ownerID = ownerID;
    }
}
